#include "includes.h"



#ifdef USE_PWM0
void Pwm0Init(uint16_t cnt, uint16_t duty)
{
	PWM0PH = (uint8_t)(cnt>>8);
	PWM0PL = (uint8_t)(cnt&0xFF);
	PWM0DH = (uint8_t)(duty>>8);
	PWM0DL = (uint8_t)(duty&0xFF);
	PWMCON |= BIT6|BIT1|BIT0;					//Enable PWM0, 8 prescaled
}
#endif	//USE_PWM0


#ifdef USE_PWM1
void Pwm1Init(uint16_t cnt, uint16_t duty)
{
	PWM1PH = (uint8_t)(cnt>>8);
	PWM1PL = (uint8_t)(cnt&0xFF);
	PWM1DH = (uint8_t)(duty>>8);
	PWM1DL = (uint8_t)(duty&0xFF);
	PWMCON |= BIT7|BIT2|BIT3;					//Enable PWM1, 8 prscaled
}
#endif	//USE_PWM1


#ifdef USE_PWM2
void Pwm2Init(uint16_t cnt, uint16_t duty)
{
	PWM2PH = (uint8_t)(cnt>>8);
	PWM2PL = (uint8_t)(cnt&0xFF);
	PWM2DH = (uint8_t)(duty>>8);
	PWM2DL = (uint8_t)(duty&0xFF);
	PWMCON1 |= BIT6|BIT0|BIT1;				//Enable PWM2, 8 prscaled
}
#endif	//USE_PWM2


#ifdef USE_PWM3
void Pwm3Init(uint16_t cnt, uint16_t duty)
{
	PWM3PH = (uint8_t)(cnt>>8);
	PWM3PL = (uint8_t)(cnt&0xFF);
	PWM3DH = (uint8_t)(duty>>8);
	PWM3DL = (uint8_t)(duty&0xFF);
	PWMCON1 |= BIT7|BIT2|BIT3;				//Enable PWM3, 8 prscaled
}
#endif	//USE_PWM2





